package jp.gnt.swf;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class Main {

	public static void main(String[] args) {
		try {
			FileOutputStream outs = new FileOutputStream(new File("/usr/tmp/swf/output.swf"));
			
			long beforeTime = System.currentTimeMillis();
			
			SWFObject obj = new SWFObject("/usr/tmp/swf/test.swf");

			Map<Integer, String> images = new HashMap<Integer, String>();
			images.put(58, "/usr/tmp/swf/slogan.png");
			images.put(55, "/usr/tmp/swf/slogan.png");
			images.put(61, "/usr/tmp/swf/slogan.png");

			obj.repairImages(images);
			
			Map<String, String> params = new HashMap<String, String>();
			params.put("upoly", "9999");
			params.put("ourl", "can test");
			params.put("cname", "本日はバトルはありません111");
			
			obj.repairParams(params);
			
			byte[] byteArrays = obj.toByteArrays();
			outs.write(byteArrays);

			long afterTime = System.currentTimeMillis();
			System.out.println("Total time: " + (afterTime - beforeTime));

			outs.flush();
			outs.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
